package com.godme.idea;

public class Fibnacci {



    public static int fibnacci(int n){
        return fibnacci(0, 1, 1, n);

    }

    public static int fibnacci(int beforeLast, int last, int iter, int target){
        if(target < 2){
            return target == 1? last: beforeLast;
        }
        if(iter == target){
            return last;
        }
        return fibnacci(last, beforeLast+last, iter+1, target);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            System.err.println(fibnacci(i));
        }
    }
}
